package com.japher.hackson;

import android.content.Context;

import com.baidu.common.preference.LxbPreference;

public class AppContext {
    
    private static AppContext instance = null;
    private Context context = null;
    @SuppressWarnings("unused")
    private static boolean running;
    private LxbPreference preference;
    
    public static synchronized AppContext getInstance() {
        if (instance == null) {
            instance = new AppContext();
            running = true;
        }
        return instance;
    }
    
    public void setContext(Context context) {
        running = true;
        if (context != null && this.context != context) {
            this.context = context;
            initApp();
        }
    }
    
    public LxbPreference getPreference() {
        return preference;
    }

    public void setPreference(LxbPreference preference) {
        this.preference = preference;
    }

    public Context getContext() {
        return context;
    }
    
    private void initApp() {
        
        preference = LxbPreference.getInstance();
        LxbPreference.getInstance().setContext(this.context);
    }
}
